<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./vue.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app">
      <!-- 
        密码强度
          数字、字母、   _*.@!#&$
          其中一种   弱
          两种      中
          三种      强

          纯数字  /^\d*$/
          纯字母  /^[A-z]*$/
          纯特殊字符  /^[_*\.@!#&$]*$/
          总的校验  /^[A-z0-9_*\.@!#&$]*$/
       -->
      <input type="text" v-model="word" @input="input" /> <span>{{text}}</span>
    </div>
  </body>
  <script>
    let app = Vue.createApp({
      data() {
        return {
          word: "",
          text: "",
          arr: ["弱", "中", "强"],
        };
      },
      methods: {
        input() {
          if (!/^[A-z0-9_*\.@!#&$]{6,12}$/.test(this.word)) {
            this.text = "不能包含非法字符,长度6-12";    
            return false;
          } else {
            this.text = "";
            // 符合规定
            let count = 0;
            if (/\d/.test(this.word)) {
              count++;
            }
            if (/[A-z]/.test(this.word)) {
              count++;
            }
            if (/[_*\.@!#&$]/.test(this.word)) {
              count++;
            }
            // 对比完毕 看count值
            this.text = this.arr[count - 1];
          }
        },
      },
    });
    app = app.mount("#app");
  </script>
</html>
